package com.liveims.webims.util;

import java.io.IOException;
import java.io.Serializable;

import javax.servlet.sip.SipServletMessage;


public class WimsMessage implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -461490618924878011L;
	private String content_type;
	private String content;
	private String from;
	
	public WimsMessage (SipServletMessage m) throws IOException{
		content_type = m.getContentType();
		byte[] c = m.getRawContent();
		content = new String(c);
		from = m.getFrom().toString();
		
		//to avoid content-type cpim
		if (content_type.equalsIgnoreCase("CPIM")){
			content_type = "text/plain";
			String s[] = content.split("\r\n");
			content = s[s.length-1];
		}
	}

	public String getContent_type() {
		return content_type;
	}

	public String getContent() {
		return content;
	}
	
	public String getFrom(){
	    return from;
	}
	

}
